actor DoomImpRes : RGAMonster
{
  spawnid 5
  obituary "%o was burned by an imp's ghost."
  hitobituary "%o was slashed by an imp's ghost."
  health 1
  radius 20
  height 56
  mass 100
  speed 10
  painchance 200
  SEESOUND "SpiritImp/Sight"
  DEATHSOUND "SpiritImp/Death"
  ACTIVESOUND "SpiritImp/Active"
  MONSTER
  +FLOORCLIP
  +NOBLOOD
  -SOLID
  Renderstyle Add
  Alpha 0.0
  dropitem "HealthBonus" 1
  Species "Imp"
  states
  {
  Spawn:
  	 SPIP A 0
	  stop
    SPIP A 0
    SPIP A 0 A_GiveInventory("XPAmount", random(6, 14))
    POSS P 0 ACS_ExecuteAlways(651,0,0,0,0)
    SPIP A 0 Thing_SetSpecial(0,226,613,0,random(6,14))    
	SPIP A 0 A_Jump(128, 2)
	SPIP A 0 A_ChangeFlag("SHOOTABLE", 0)
    SPIP A 0 A_JumpIfInventory("Awoken",1,"Look")
    SPIP AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 A_FadeIn(0.025)
    Goto Spawn+4
  Look:
    SPIP A 0 A_GiveInventory("Awoken",1)
    SPIP AB 10 A_Look
    loop
  See:
	SPIP A 0 A_Jump(140, 3)
	SPIP A 0 A_ChangeFlag("SHOOTABLE", 1)
	SPIP A 0 A_Jump(255, 2)
	SPIP A 0 A_ChangeFlag("SHOOTABLE", 0)	
    SPIP AABBCCDD 3 A_Chase
    loop
  Melee:
  Missile:
    SPIP EF 8 A_FaceTarget
    SPIP G 6 A_CustomMissile("SpiritImpBall",30,0,5)
    goto See
  Missile2:
    SPIP EF 8 A_FaceTarget
    SPIP G 0 A_CustomMissile("SpiritImpBall",30,0,5)
    SPIP G 0 A_CustomMissile("SpiritImpBall",30,0,-5)
    SPIP G 6 A_CustomMissile("SpiritImpBall",30,0,0)
    goto See
  Pain:
    SPIP N 3
    SPIP N 3 A_Pain
	TNT1 N 0 A_AlertMonsters
    Goto See
  Death:
    SPIP PQR 4 
    SPIP S 4 A_SpawnItemEx("HealthBonus",0,0,0,random(-2,2),random(-2,2),random(1,4),0,0,0)
    SPIP T 3 A_Fall
	SPIP T 0 A_KillChildren
	SPIP T 0 ACS_ExecuteAlways(648,0,0,0,0)
    SPIP U 3 
    SPIP V 3 A_NoBlocking
  FadeOut:
    SPIP W 3 A_FadeOut(0.015)
    loop
  Raise:
    SPIP ML 8
    SPIP KJI 6
    goto See
  }
}

actor SpiritImpBall
{
    Radius 8
    Height 6
    Scale 0.4
    Speed 9
    Damage 2
	ReactionTime 100
    +SEEKERMISSILE
    PROJECTILE
    Renderstyle ADD
    SeeSound "harvester/scream"
    DeathSound "imp/shotx"
    Decal DoomImpScorch
    States
    {
    Spawn:
    	SIBA A  0 A_SpawnItemEx("SpiritImpBallTrail", 0, 0, 0, 0, 0, 0, 0, 180)
        SIBA AB 2 A_SeekerMissile (10,20)
		SIBA B 0 A_Countdown
        Loop
    Death:
        SIBA CDEFGHIJKL 4 
        Stop
    }
}


actor SpiritImpBallTrail
{
    Radius 1
    Height 1
    Speed 0
    PROJECTILE
    RENDERSTYLE ADD
    ALPHA 0.5
    +NOCLIP
    States
    {
    Spawn:
    Death:
    	SITR H 6 
        SITR ABCDEFG 4 
        Stop
    }
}



actor OrbitSpirit : SpiritImpBall
{
     SeeSound ""
     +NOCLIP
     Scale 0.4
     Alpha 0.1
     Speed 3
     MissileHeight 0
     States
     {
     Spawn:
         SIBA AABB 1
         SIBA A 3 A_CustomMissile("OrbitSpirit", 0, 0, 75)
         Stop
     Death:
    	 SIBA A 2 A_FadeOut(0.015)
         loop
     }
}

actor OrbitSpirit2 : OrbitSpirit
{
     Speed 10
     MissileHeight 0
     States
     {
     Spawn:
         SIBA AABB 1
         SIBA A 0 A_CustomMissile("OrbitSpirit", 0, 0, -75)
         stop
     Death:
    	 SIBA A 2 A_FadeOut(0.015)
         loop
     }
}


actor SpiritImpGhost1
{
    Radius 1
    Height 1
    Speed 0
    PROJECTILE
    RENDERSTYLE ADD
    ALPHA 0.7
    +NOCLIP
    SeeSound "harvester/ghost"
    States
    {
    Spawn:
    Death:
        SIGH A 0
        SIGH A 0 A_PlaySound("harvester/ghost")
        SIGH ABCDEFG 4 
        Stop
    }
}

Actor SpiritImpGhost
{
  Radius 20
  Height 56
  Mass 120
  Speed 8
  renderstyle add
  alpha 0.2
  +NOTELEPORT
  +FLOORCLIP
  -SOLID
  -SHOOTABLE
  +NONSHOOTABLE
  +LOOKALLAROUND
  States
  {
  Spawn:
    SPIP AABB 6 A_Look
    SPIP A 0 A_FadeOut(0.005)
    Loop
  See:
    SPIP AABBCCDD 3 A_VileChase
    SPIP A 0 A_FadeOut(0.005)
    Loop
  Death:
    TNT1 A 1
    Stop
  Heal:
    TNT1 A 1
    Goto Death
  }
}

